home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / sphigs / sph_dos.lha / dos / srgpdemo / testpain.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-26  |  2.2 KB  |  89 lines

  1. #include "srgp.h"
  2. #include <stdio.h>
  3.  
  4. /* TEST OF LOCATOR SAMPLE MODE. */
  5.  
  6. /* Left button paints in red, middle in green, right in blue.
  7.    Multiple buttons lead to color mixing.
  8.  */
  9.  
  10.  
  11. #define DLM   deluxe_locator_measure
  12.  
  13. int
  14. LocatorMeasuresEqual(DLM first, DLM second)
  15.  
  16. {
  17. return (
  18.  
  19.     (first.position.x == second.position.x) && 
  20.     (first.position.y == second.position.y) &&
  21.  
  22.     (first.button_chord[0] == second.button_chord[0]) &&  
  23.     (first.button_chord[1] == second.button_chord[1]) &&  
  24.     (first.button_chord[2] == second.button_chord[2]) &&
  25.  
  26.         (first.modifier_chord[0] == second.modifier_chord[0]) &&  
  27.     (first.modifier_chord[1] == second.modifier_chord[1]) &&  
  28.     (first.modifier_chord[2] == second.modifier_chord[2]) 
  29.   );
  30. }
  31.  
  32. DLM
  33. WaitForAnyChange (DLM original)
  34. {
  35.    DLM    retval;
  36.  
  37.    SRGP_sampleDeluxeLocator(&retval);
  38.    while ( LocatorMeasuresEqual(original, retval) )
  39.       SRGP_sampleDeluxeLocator(&retval);
  40.  
  41.    return(retval);
  42. }
  43.  
  44. main()
  45. {
  46.    DLM locmeasure;
  47.    int col;
  48.    char buff[10];
  49.  
  50.    SRGP_begin ("Painting application", SCREEN_WIDTH, SCREEN_HEIGHT, 3, FALSE);
  51.  
  52.    SRGP_loadCommonColor (0, "black");
  53.    SRGP_loadCommonColor (1, "blue");
  54.    SRGP_loadCommonColor (2, "green");
  55.    SRGP_loadCommonColor (3, "cyan");
  56.    SRGP_loadCommonColor (4, "red");
  57.    SRGP_loadCommonColor (5, "magenta");
  58.    SRGP_loadCommonColor (6, "yellow");
  59.    SRGP_loadCommonColor (7, "white");
  60.  
  61.  
  62.    SRGP_setLocatorEchoType (CURSOR);
  63.    SRGP_setFillStyle(BITMAP_PATTERN_OPAQUE);
  64.    SRGP_setLocatorButtonMask
  65.       (LEFT_BUTTON_MASK | MIDDLE_BUTTON_MASK | RIGHT_BUTTON_MASK);
  66.    SRGP_setInputMode(LOCATOR, SAMPLE);
  67.    SRGP_setInputMode(KEYBOARD, SAMPLE);
  68.    SRGP_setKeyboardProcessingMode (RAW);
  69.  
  70.    while (1) {
  71.       SRGP_sampleDeluxeLocator (&locmeasure);
  72.       col = 0;
  73.       if (locmeasure.button_chord[LEFT_BUTTON]==DOWN) col += 4;
  74.       if (locmeasure.button_chord[MIDDLE_BUTTON]==DOWN) col += 2;
  75.       if (locmeasure.button_chord[RIGHT_BUTTON]==DOWN) col += 1;
  76.       if (col > 0) {
  77.          SRGP_setColor (col);
  78.          SRGP_setFillBitmapPattern (col);
  79.          SRGP_fillRectangleCoord
  80.            (locmeasure.position.x-5, locmeasure.position.y-5,
  81.             locmeasure.position.x+5, locmeasure.position.y+5);
  82.          }
  83.       SRGP_sampleKeyboard (buff, 10);
  84.       if (strlen(buff) > 0)
  85.          break;
  86.    }
  87.    SRGP_end();
  88. }
  89.